﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using HYCodeBase.CommonUtility.CompareUtility;

namespace HYRevitCode.RevitObjectCompareUtility
{
	public class XYZEqualityComparer : IEqualityComparer<XYZ>
	{
		public void SetPrecision(uint input)
		{
			this.m_useDoubleEqualityComparer.SetPrecision(input);
		}

		public bool Equals(XYZ p, XYZ q)
		{
			return p.IsAlmostEqualTo(q, this.m_useDoubleEqualityComparer.UseTolerance);
		}

		public int GetHashCode(XYZ p)
		{
			string doubleString = this.m_useDoubleEqualityComparer.GetDoubleString(p.X);
			string doubleString2 = this.m_useDoubleEqualityComparer.GetDoubleString(p.Y);
			string doubleString3 = this.m_useDoubleEqualityComparer.GetDoubleString(p.Z);
			return string.Concat(new string[]
			{
				"(",
				doubleString,
				",",
				doubleString2,
				",",
				doubleString3,
				")"
			}).GetHashCode();
		}

		private DoubleEqualityComparer m_useDoubleEqualityComparer = new DoubleEqualityComparer();
	}
}
